package com.shaw.workrecord.controller;

import com.shaw.workrecord.entity.ResponseBean;
import com.shaw.workrecord.pojo.request.RegisterRequest;
import com.shaw.workrecord.service.IRegisterService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author jh.jiang
 * date 2022-08-28
 * description
 */
@RestController
@Api(tags="注册模块")
@Validated
public class RegisterController {

    @Autowired
    private IRegisterService service;

    @PostMapping("/register")
    @ApiOperation("注册")
    public ResponseBean<Boolean> register(@RequestBody RegisterRequest request) {
        if (service.register(request)) {
            return ResponseBean.success(true);
        }
        return ResponseBean.failure("注册失败");
    }
}
